package com.zabra.zl.ui.recall;

import android.graphics.Color;
import android.support.annotation.Nullable;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.orhanobut.logger.Logger;
import com.zabra.zl.R;
import com.zabra.zl.data.OrderListBean;
import com.zabra.zl.utils.BaseUtils;

import java.util.ArrayList;
import java.util.List;


public class Adp extends BaseQuickAdapter<OrderListBean.RespDataBean, BaseViewHolder> {
    private int selectItem = -1;

    public Adp(int layoutResId, @Nullable List<OrderListBean.RespDataBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, OrderListBean.RespDataBean item) {
        String[] strings = BaseUtils.spliteUtils(item.getSharesCode(), "-");
        helper.setText(R.id.item_name, strings[1])
                .setText(R.id.item_code, strings[0])
                .setText(R.id.item_price, item.getEntrustPrice() + "")
                .setText(R.id.item_num, item.getEntrustNum()+"")
                .setText(R.id.item_type, item.getEntrustType() == 1 ? "买入" : "卖出")
                .setText(R.id.item_date, item.getExtendAddTimeStart());
        CheckBox checkBox = helper.getView(R.id.item_cb);
        if (helper.getAdapterPosition() == selectItem) {
            //选中
            checkBox.setChecked(true);
        } else {
            //未选中
            checkBox.setChecked(false);
        }
    }

    public void setSelectItem(int selectItem) {
        this.selectItem = selectItem;
    }
}